<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/08/20 0020
 * Time: 11:53:09
 */
namespace app\admin\Controller;
use app\common\controller\Curt;
use think\Db;

class Recharge extends Curt{
    public function getall()
    {
        $keyword=input('get.keyword');
        if($keyword){
            $where['b.user_realname']=['like','%'.$keyword.'%'];//模糊查询or可以一个条件中写多个字段以‘|’分开
            $this->assign('keyword',$keyword);
        }
        //支付类型
        $r_paytype=trim(input('get.r_paytype'));
        if($r_paytype){
            $where['a.r_paytype']=$r_paytype;
            $this->assign('r_paytype',$r_paytype);
        }
        //支付状态
        $r_state=trim(input('get.r_state'));
        if($r_state){
            $where['a.r_state']=$r_state;
            $this->assign('r_state',$r_state);
        }
        //开始时间 - 结束时间
        $begin=trim(input('get.begin'));
        $end=trim(input('get.end'));
        if($begin&&$end){
            $where['a.r_addtime'] =['between',[strtotime($begin.' '.'00:00:00'),strtotime($end.' '.'23:59:59')]];
        }
        if(!$begin&&$end){
            $where['a.r_addtime'] =['between',[time(),strtotime($end.' '.'23:59:59')]];
        }
        if($begin&&!$end){
            $where['a.r_addtime'] =['between',[strtotime($begin.' '.'00:00:00'),time()]];
        }
        $this->assign('begin',$begin);
        $this->assign('end',$end);
        $list=Db::name('recharge')->alias('a')
            ->join('ec_user b','a.user_id=b.id',left)
            ->where($where)
            ->field('a.*,b.user_realname')
            ->order('a.id desc')
            ->paginate();
        //dump($this->model->getLastSql());
        $page = $list->render();
        $listinfo=$list->toArray();
        $this->assign(
            ['recharge'=>$listinfo['data']],
            ['page'=>$page]
        );

    }

}